<template>
	<scroll-view scroll-y="true" @scrolltolower="getNextPageData" class="body">
		<view v-for="(item, index) in list" :key="index" class="card">
			<view class="title flex-row">主&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题：{{ item.topic }}</view>
			<view class="title flex-row">
				<view>类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：{{ item.type }}</view>
				<view style="width: 50%;">专家名称：{{ item.teacher }}</view>
			</view>
			<view class="item flex-row"><view>创建时间：{{ item.addtime }}</view></view>
			<view class="item flex-row"><view>开始时间：{{ item.start_time }}</view></view>
			<view class="item flex-row"><view>结束时间：{{ item.over_time }}</view></view>
			<view class="item flex-row"><view>学习时长：{{ item.study_time || 0 }}分钟</view></view>
		</view>
		<view class="nodata">没有更多了~</view>
	</scroll-view>
</template>

<script>
export default{
	data(){
		return {
			userid: uni.getStorageSync('userid'),
			miss_id: '',
			page: 1,
			total: 1,
			list: []
		}
	},
	onLoad(option){
		this.miss_id = option.id;
		this.getList();
	},
	methods: {
		// 获取列表
		getList(){
			let _this = this;
			uni.request({
				url: this.$API.eduVideoMyTaskLog,
				data: { userid: this.userid, miss_id: this.miss_id },
				header: this.$API.get_head(),
				success: (res)=>{
					_this.total = res.data.total;
					
					// 判断是第一页还是后续页
					let data = res.data.rows;
					if(_this.page == 1){
						_this.list = data;
					}else{
						_this.list = _this.list.concat(data);
					}
				}
			})
		},
		// 分页加载
		getNextPageData(){
			console.log(1);
			this.page++;
			if(this.page < this.total){
				this.tabIndex == 3 ? this.getRecordList() : this.getList();
			}
		}
	}
}
</script>

<style scoped>
.body{
	height: 100vh;
}
.card{
	margin: 20upx 20upx 0;
	border-radius: 16upx;
	background: #fff;
	padding: 14upx 20upx 8upx;
	border: 2upx solid #F6F6F6;
	box-shadow: 0 0 4upx #eee;
}
.card .title{
	margin-bottom: 6upx;
}
.card .title view{
	height: 42upx;
	font-size: 28upx;
}
</style>
